// pages/corporate/talent/index.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    selectedEducation: "学历",
    educationList: ["不限", "小学","初中","高中", "中专", "大专", "本科", "硕士", "博士"],
    isBottomSheetVisible: false,
    sheetType: "",
    genderList: ["18岁-25岁", "36岁-40岁", "51岁-55岁","26岁-30岁", "41岁-45岁", "56岁及以上","31岁-35岁", "46岁-50岁", "全部年龄"],
    selectedGender: "年龄",
    work_list : [
      '分拣员','快递员','跑腿代办','送货司机','安保','建筑/房地产','驾驶员','装卸/搬运','驾驶员','操作工','物流','司机','交通/物流/仓储'
    ],
    work_type_list : [
      '物流配送','营销宣传','行政','服务业','市场营销','餐饮行业','影视传媒'
    ],
    selectedWorkType:"",
    selectedWork:"全部工种",
    area_cat      : ['威海市'],
    area_type_list : ["环翠区", "乳山市", "荣成市","文登区"],
    area_type      : '区域',
    jobTypeIcon: "cuIcon-unfold",
    jobLocationIcon: "cuIcon-unfold",
    educationIcon: "cuIcon-unfold",
    genderIcon: "cuIcon-unfold",
    workTypeIcon: "cuIcon-unfold",
    userList: [
      {
        name: "张先生",
        gender: "男",
        age: 57,
        other: "其他",
        region: "岗王镇",
        job: "暂无",
        avatar: "http://image.spxlgsc.com/04.png",
      },
      {
        name: "李女士",
        gender: "女",
        age: 45,
        other: "无",
        region: "西湖区",
        job: "自由职业",
        avatar: "http://image.spxlgsc.com/04.png",
      },
      {
        name: "王先生",
        gender: "男",
        age: 60,
        other: "退休",
        region: "东城区",
        job: "顾问",
        avatar: "http://image.spxlgsc.com/04.png",
      },
    ],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

     //区域选择
     toggleAreaPicker(e){
        
      const index = e.detail.value
    
      this.setData({
        area_type : this.data.area_type_list[index]
      })
  },

     //关闭弹窗
     closePopup() {
      this.setData({
        isBottomSheetVisible: false,
      });
    },
    nav_to(e){
      const url = e.currentTarget.dataset.url
      wx.reLaunch({
        url: url,
      })
    },
    // 选择弹出层选项
    selectSheetOption(e) {
      const value = e.currentTarget.dataset.value;
      if (this.data.sheetType === "education") {
        this.setData({ selectedEducation: value });
      } else if (this.data.sheetType === "gender") {
        this.setData({ selectedGender: value });
      }else if (this.data.sheetType === "workType") {
        this.setData({ selectedWork: value });
      }else if (this.data.sheetType === "jobLocation") {
        this.setData({ area_type: value });
      }
    },


        // 确认弹出层
  confirmBottomSheet() {
    console.log(`确认选择：${this.data.selectedEducation || this.data.selectedGender}`);
    this.closeBottomSheet();
  },

    // 关闭弹出层
    closeBottomSheet() {
      const iconKey = `${this.data.sheetType}Icon`;
      this.setData({
        isBottomSheetVisible: false,
        [iconKey]: "cuIcon-unfold",
      });
    },

       //选择岗位类型
       select_work_type(e){
        const value = e.currentTarget.dataset.value;
        this.setData({ selectedWorkType: value });
      },
  
      //选择职位
      select_work(e){
        const value = e.currentTarget.dataset.value;
        this.setData({ selectedWork: value });
      },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },
    // 显示底部弹出层
    showBottomSheet(e) {
      const type = e.currentTarget.dataset.type;
      const iconKey = `${type}Icon`;
      this.setData({
        sheetType: type,
        isBottomSheetVisible: true,
        [iconKey]: "cuIcon-fold",
      });
    },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})